﻿using System;
using System.Collections.Generic;

using System.Text;
using Microsoft.Xna.Framework;

namespace RebEngine.GameComponents
{
    public enum GameSpeed
    {
        Pause = 300,
        VerySlow = 18,
        Slow = 12,
        MediumSlow = 8,
        Medium = 5,
        Fast = 2
    };

    public class Tick : GameComponent
    {
        static int iTick;

        public static int GetTick
        {
            get { return iTick; }
        }

        public delegate void Fire();
        public static event Fire TickTimerFinished;

        static GameSpeed eCurrentSpeed;
        static double delta;

        public Tick(Game game)
            :base(game)
        {
            iTick = 0;
            eCurrentSpeed = GameSpeed.Fast;
        }

        public override void Update(GameTime gameTime)
        {
            delta += gameTime.ElapsedGameTime.TotalSeconds;
            if ((int)delta >= (int)eCurrentSpeed)
            {
                iTick++;
                if (TickTimerFinished != null)
                    TickTimerFinished();
                delta = 0;
            }
        }
    }
}
